package com.app.mvvmkotlindemo

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Looper
import androidx.multidex.MultiDex
import com.blankj.utilcode.util.LogUtils
import com.everyline.baselibrary.base.BaseApp
import com.tencent.mmkv.MMKV
import io.reactivex.plugins.RxJavaPlugins


/**
 * Created by on 2020/11/23.
 * 天天挂线
 *  746608431@qq.com
 *  描述:TODO
 */

class KQApp : BaseApp() {

    private var service: Intent? = null


    companion object {
        lateinit var instance: KQApp

        var isDriving = 3


    }

    @SuppressLint("RestrictedApi")
    override fun onCreate() {
        super.onCreate()

        instance = this
        LogUtils.getConfig().isLogSwitch = BuildConfig.DEBUG
        MMKV.initialize(this)


        initUmeng()
        //RxJava2 取消订阅后，抛出的异常无法捕获，导致程序崩溃
        RxJavaPlugins.setErrorHandler { throwable ->
            LogUtils.d(
                "KQApp===RxJavaPlugins抛出的异常",
                throwable.message + "===" + throwable.cause
            )
        }

        object : ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {

            }

            override fun onActivityStarted(activity: Activity) {



            }

            override fun onActivityResumed(activity: Activity) {

            }

            override fun onActivityPaused(activity: Activity) {

            }

            override fun onActivityStopped(activity: Activity) {

            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {

            }

            override fun onActivityDestroyed(activity: Activity) {

            }

        }
    }

    private fun initUmeng() {




    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(base)

    }



}